package com.example.demo.mapper;

import com.example.demo.entity.Artical;
import com.example.demo.entity.ArticleVO;
import com.example.demo.entity.Shouye;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

@Mapper
@Repository
public interface ListMapper {
    public List<Artical> list();
    @Select("select * from t_comment")
    public List<Artical> getlist();
    //查询分页
//    @Select("select * from t_comment limit #{b},#{limit}")
    List<Artical> getpage(ArticleVO articleVO);
    //查询所有条数
//    @Select("select count(*) from t_comment")
    Integer getcount(ArticleVO articleVO);
    //删除数据
    @Delete("delete from t_comment where id=#{id}")
    public Integer delete(Integer id);
    //id查询
    @Select("select * from t_comment where id=#{id}")
    public Artical tanchu(Integer id);
    //更新
    @Update("update t_comment SET sex=#{sex},created=#{created},content=#{content},status=#{status},checkboxx=#{checkboxx},close=#{close},brithday=#{brithday},username=#{username},phone=#{phone},name=#{name},email=#{email},password=#{password} where id=#{id}")
    public int update(Artical artical);
    @Update("update t_comment SET sex=#{sex},username=#{username},phone=#{phone},name=#{name},status=#{status},email=#{email},password=#{password} where id=#{id}")
    public int update1(Artical artical);
    //批量删除
//    @Delete("delete from t_comment where id=#{id}")
    Integer Bydelete(Integer[] id);
    //添加
    @Insert("INSERT INTO t_comment (id,  created, ip, content, status, sex, brithday, password, username, phone, name, email, beizhu) " +
            "VALUES (#{id},  #{created}, #{ip}, #{content}, #{status}, #{sex}, #{brithday}, #{password}, #{username}, #{phone}, #{name}, #{email}, #{beizhu})")
    @Options(useGeneratedKeys = true, keyProperty = "id" , keyColumn = "id")
    public Integer insert(Artical artical);

    //多条件查询
    List<Artical> search(Artical artical);

    //登录
    public Artical login(Artical artical);

    //用户查询
    List<Artical> getpage1(ArticleVO articleVO);
    Integer getcount1(ArticleVO articleVO);

    //开关更新
    @Update("update t_comment SET close=#{close} where id=#{id}")
    public int updateclose(Artical artical);

    //点击量
    @Update("UPDATE today SET today_access=today_access+1 where id=1")
    public int dianjiliang(Shouye shouye);
}
